<template>
    <div class="commentItem">
      <div>
        <div class="commentItem-title">
          <img :lazy-load="true"  :src="item.comment_user_head_img ? picPre + item.comment_user_head_img : picPre + 'front/avatar.jpg'" alt="">
          <div class="commentItem-name">
            <h1>{{item.comment_username}}</h1>
            <p>{{item.created_at}}</p>
          </div>
          <i class="iconfont iconshanchu" v-if="del" ﻿@tap="delBtn(item.comment_id)" style="font-size: 20rpx;color: #CECECE;"></i>
        </div>
        <p><rich-text :nodes="item.comment_describe"></rich-text></p>
        <div class="commentItem-post" ﻿@tap="goPage(item.posts_id)">
          <img :src="picPre + item.posts_img[0]" v-if="item.posts_img.length>0 && item.posts_img[0] !== '' " alt="">
          <p>
           {{item.posts_title}}
          </p>
          <i class="iconfont iconyou" style="color: #A4A3AB;"></i>
        </div>
      </div>
    </div>
</template>

<script>
    export default {
        name: "index",
      props:{
          item:{
            type:Object
          },
        del:{
            type: Boolean,
          default:true
        }
      },
      data(){
        let that = this;
        return{
          picPre: that.$api.picPre,
          }
      },
      methods:{
          goPage(id) {
            if(this.item.posts_deleted_type === 1){
				uni.navigateTo({
					url: '/movie/postDetails?id=' + id
				})
            } else {
              ﻿uni.showToast({
                title: '该帖子已不存在',
                icon: 'none',
                duration: 2000
              })
            }
          },
          delBtn(id){
            let that = this
            ﻿uni.showModal({
              title: '删除评论',
              content: '确认删除？',
              success (res) {
                if (res.confirm) {
                  that.$ajax
              .post(that.$api.deleteMemberComment, {comment_id: id})
              .then(() => {
                that.$emit("delComment", id)
              })
              .catch(err => {
                ﻿uni.showToast({
                  title: err,
                  icon: 'none',
                  duration: 2000
                })
              });
                }
              }
            });
          }
      }
    }
</script>

<style scoped>
.commentItem{
  padding: 0 30rpx;
  box-sizing: border-box;
}
  .commentItem>div{
    padding: 30rpx 0;
    border-bottom: 14rpx solid #F7F7F7;
  }
  .commentItem-title{
    display: flex;
    justify-content: space-between;
  }
.commentItem-title>img{
  width: 64rpx;
  height: 64rpx;
  border-radius: 50%;
}
.commentItem-name{
  padding-top: 9rpx;
  padding-left: 16rpx;
  flex: 1;
}
.commentItem-name>h1{
  font-size: 24rpx;
  color: #7A7A7A;
  font-weight: bold;
  line-height: 20rpx;
}
.commentItem-name>p{
  font-size: 20rpx;
  color: #ADADAD;
  font-weight: bold;
  line-height: 20rpx;
  margin-top: 10rpx;
}
  .commentItem-title+p{
    font-size: 30rpx;
    color: #323232;
    line-height: 30rpx;
    font-weight: bold;
    padding: 23rpx 0 28rpx;
  }

  .commentItem-post{
    padding: 20rpx;
    box-sizing: border-box;
    background-color: #F6F6F8;
    border-radius: 10rpx;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
.commentItem-post>img{
  width: 76rpx;
  height: 76rpx;
  border-radius: 10rpx;
  margin-right: 29rpx;
}
.commentItem-post>p{
  font-size: 24rpx;
  color: #323232;
  line-height: 29rpx;
  font-weight: bold;
  flex: 1;
  margin-right: 64rpx;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
</style>
